/**
 * 
 */
package com.dalonedrow.engine.sprite.impl;

import com.badlogic.gdx.Gdx;
import com.dalonedrow.engine.sprite.base.SpriteBase;
import com.dalonedrow.engine.sprite.base.SpriteImageObjectFactory;
import com.dalonedrow.engine.systems.JOGLErrorHandler;
import com.dalonedrow.engine.systems.Render;
import com.dalonedrow.globalvariables.constants.hq.GlobalConstants;

/**
 * @author Donald
 */
public class SoftwareCursor {
	private static SoftwareCursor instance;
	/**
	 * Gets the singelton instance of {@link SoftwareCursor}.
	 * @return {@link SoftwareCursor}
	 */
	public static SoftwareCursor getInstance() {
		if (instance == null) {
			instance = new SoftwareCursor();
		}
		return instance;
	}
	private SoftwareCursor() { 
		sprite = new BasicSpriteObject();
		sprite.setHeight(32);
		sprite.setWidth(32);
	}
	private SpriteBase	sprite;
	public void switchCursor(final int cursor) throws Exception {
		switch (cursor) {
		case GlobalConstants.CURSOR_00_DEFAULT:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"default_cursor"));
			break;
		case GlobalConstants.CURSOR_03_WAIT:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"wait_cursor"));
			break;
		case GlobalConstants.CURSOR_12_HAND:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_20_PAN_NORTHWEST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_21_PAN_NORTH:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_22_PAN_NORTHEAST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_23_PAN_EAST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_24_PAN_SOUTHEAST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_25_PAN_SOUTH:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_26_PAN_SOUTHWEST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_27_PAN_WEST:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_28_MOVE:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		case GlobalConstants.CURSOR_29_ATTACK:
			sprite.setImageRefId(
					SpriteImageObjectFactory.getInstance().getImageRefId(
							"hand_cursor"));
			break;
		default:
			JOGLErrorHandler.getInstance().fatalError(
					new Exception(
							"Invalid cursor type: " + cursor));
			break;
		}
	}
	public void render() throws Exception {
		sprite.setPosition(Gdx.input.getX(), 
				GlobalConstants.SCREEN_HEIGHT - Gdx.input.getY() - 28, 
				1);
		Render.getInstance().registerEntity(sprite);
		Render.getInstance().render();
	}
}
